// 
// 
// 

#include "PellClass.h"
#include "ControlPanelClass.h"

#ifndef ledb1
#include "constants.cpp"
#endif



void PellClass::setup()
{
	if(State != NOT_INITIALIZED){
		return;
	}
	// These must be done in the setup routine

	ControlPanel.setup();

	// Prepare Targets
	Target1 = new PellTargetClass(ledr1,ledg1,ledb1,FSR1);
	Target1->init();
	Target2 = new PellTargetClass(ledr2,ledg2,ledb2,FSR2);
	Target2->init();
	Target3 = new PellTargetClass(ledr3,ledg3,ledb3,FSR3);
	Target3->init();
	Target4 = new PellTargetClass(ledr4,ledg4,ledb4,FSR4);
	Target4->init();
	Target5 = new PellTargetClass(ledr5,ledg5,ledb5,FSR5);
	Target5->init();
	Target6 = new PellTargetClass(ledr6,ledg6,ledb6,FSR6);
	Target6->init();

	State = INITIALIZING_1;
	
}


PellClass::PellClass(){
	State = NOT_INITIALIZED;
}

void PellClass::Update()
{
	int reading = 0;
	// Primary work is performed here
	switch (State)
	{
	case NOT_INITIALIZED:
		// Do Nothing
	case INITIALIZING_1:
		

		State = INITIALIZING_2;
	
		break;
	case INITIALIZING_2:
		

		State = INITIALIZING_3;
		break;
	case INITIALIZING_3:
		
		State = READY;
		break;
	case READY:
		// Ready Work here
		// Keep the Control Panel Updated
		ControlPanel.update();
		
		break;
	case RUNNING_PROGRAM:
		if(ControlPanel.MenuButtonPressed())
		{
			//Menu/Cancel button pressed...exit this run
			State = PROGRAM_CANCELED;
			break;
		}
		// In Program Work Here
		

		break;
	case PROGRAM_CANCELED: 
		// TODO: Any Cancellation cleanup here

		State = READY;
		break;
	default: break;
	}

	return;
}



PellClass Pell;

